package judge.domain;

import core.enums.CodeRunStatus;
import lombok.Data;

import java.util.List;

@Data
public class SandBoxExecuteResult {
    private CodeRunStatus runStatus; // 执行结果

    private String exeMessage; // 异常信息

    private List<String> outputList;

    private Double useMemory;

    private Long useTime;


    public static SandBoxExecuteResult fail(CodeRunStatus status) {
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setRunStatus(status);
        return result;
    }

    public static SandBoxExecuteResult fail(CodeRunStatus status, String message) {
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setExeMessage(message);
        result.setRunStatus(status);
        return result;
    }

    public static SandBoxExecuteResult fail(CodeRunStatus status, List<String> outputList,
                                            Double useMemory, Long useTime) {
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setRunStatus(status);
        result.setExeMessage(status.getMessage());
        result.setOutputList(outputList);
        result.setUseMemory(useMemory);
        result.setUseTime(useTime);
        return result;
    }

    public static SandBoxExecuteResult success(CodeRunStatus status, List<String> outputList,
                                               Double useMemory, Long useTime) {
        SandBoxExecuteResult result = new SandBoxExecuteResult();
        result.setRunStatus(status);
        result.setOutputList(outputList);
        result.setUseMemory(useMemory);
        result.setUseTime(useTime);
        return result;
    }
}
